package statcomponent.rules;

import constants.NumberConstants;
import statcomponent.AbstractStatRule;

import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

/**
 * Long类型-统计规则
 *
 * @author chenfoxin
 * @date 2022年09月05日 9:58
 */
public class LongStatRule extends AbstractStatRule<Long,Long> {
    private final AtomicLong result = new AtomicLong(NumberConstants.LONG_ZERO);

    @Override
    public void doStat(Long statValue) {
        result.addAndGet(Objects.isNull(statValue) ? NumberConstants.LONG_ZERO : statValue);
    }

    @Override
    public Long result() {
        return result.get();
    }
}